/*
*	create by  jack ,20210705
*	
*	描述 ：
*		  该文件提供了一套设备调用的接口，屏蔽具体实现细节,以达到应用程序可以在不同的平台上联合调试。
*		  open 返回该设备枚举类别。无设备实现时，返回负数.
*   修改记录：[内容][作者][时间]
*	
*/


#ifndef _SANJI_OS_DEVICE_H_
#define _SANJI_OS_DEVICE_H_

#include "define_comm.h"
#include "file_operation.h"
#include "klist.h"

struct device_driver;
struct device {
	const char		*init_name; /* initial name of the device */
	const char 	*compatibility;
	struct device_driver *driver;
	sj_uint32			id;	/* device instance */
        sj_void 			*private_data;
};

struct device_id_table
{
	char *name;
};

struct device_driver {
	const char		*name;
	const struct device_id_table *id_table;
	struct file_operations *opt;	
	sj_int32 (*probe) (struct device *dev);
	sj_int32 (*remove) (struct device *dev);
	sj_void (*shutdown) (struct device *dev);
	sj_int32 (*suspend) (struct device *dev, sj_int32 state);
	sj_int32 (*resume) (struct device *dev);
};


#define   get_device_id(dev)  dev->id
#define   get_device_driver_opt(driver) driver->opt
#define   get_device_data(dev) dev->private_data


#define DRIVER_MODULE_INIT(name) KLIST_NODE_INIT(name##_node,&(name));\
        struct klist_node *get_##name##_node(void) {return &name##_node;}

#define DEVICE_MODULE_INIT(name) KLIST_NODE_INIT(name##_node,&(name));\
        struct klist_node *get_##name##_node(void) {return &name##_node;}

#endif
